﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class HistoryTrans : System.Web.UI.Page
{
    BankServices.BankingServices sv = new BankServices.BankingServices();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitContent();
        }
    }

    private void InitContent()
    {

        if (!Session["AccountID"].Equals(""))
        {
            int aid = int.Parse(Session["AccountID"].ToString());
            lvHistory.DataSource = sv.GetHistoryTrans(aid);
            lvHistory.DataBind();
        }

    }


    protected void btnSearch_Click(object sender, EventArgs e)
    {
        int optionStatus = -1;
        if (rdAll.Checked)
        {
            optionStatus = -1;
        }
        else if (rdNotComplete.Checked)
        {
            optionStatus = 0;
        }
        else if (rdComplete.Checked)
        {
            optionStatus = 1;
        }
        else
        {
            optionStatus = 2;
        }

        int accountID;
        if (!txtAccountID.Text.Equals(""))
        {
            accountID = int.Parse(txtAccountID.Text);
        }
        else {
            accountID = 0;
        }
        
        
        int byDateOp = 0;
        if (ckTime.Checked)
        {
            byDateOp = 1;
        }
        else
        {
            byDateOp = 0;
        }

        string fromDate = txtFromDate.Text;
        string toDate = txtToDate.Text;

        lvHistory.DataSource = sv.SearchHistoryTrans(optionStatus, accountID, byDateOp, fromDate, toDate);
        lvHistory.DataBind();
    }
}